import comSpSkeleton from "../../../../engines/components/comSpSkeleton";
import O1HD, { managers } from "../../../../engines/gameEngine";
import mainRoot from "../../../../Game/MainRoot";
import InGamePage from "../../../../Game/Page/InGamePage";
import LevelLianXian_1, { LianXianWayPoint } from "./LevelLianXian_1";

const {ccclass, property} = cc._decorator;

enum NODEROTATION{
    LEFT,
    RIGHT
}

@ccclass
export default class LevelLianXian_1Item extends cc.Component {

    /**当前标签 */
    @property({type:cc.Integer,displayName:"当前item标签"})
    currentNum:number = 0;
    /** 对应标签 */
    @property({type:cc.Integer,displayName: "对应标签" })
    tagNum: number[] = [];
    /** 音频时间 */
    @property({ type: cc.Integer, displayName: "音频时间/秒" })
    soundTimeLeft: number = 0;
    /** 毫秒 */
    @property({ type: cc.Integer, displayName: "音频时间/毫秒" })
    soundTimeRight: number = 0;

    @property({type:cc.Enum(NODEROTATION)})
    nodeRotation:NODEROTATION = NODEROTATION.LEFT;

    @property({displayName:"点击是否播放音效"})
    clickIsPlaySound:boolean = true;

    oldSoundTime: number = 0;

    @property({type:cc.Node,displayName:"关卡脚本"})
    levelNode:cc.Node = null;

    /** level140脚本 */
    level1Script: LevelLianXian_1 = null;
    /** 是否不能选中 */
    isBuNengSelect: boolean = false;
    /**是否在抖动的动画中 */
    isTweenAni:boolean = false;

    currentTime:number = 0;

    startCount: boolean = false;

    isStartSoundTime: boolean = false;

    startTouchTime: number = 0;
    /** 触摸屏幕的初始位置 */
    startTouchPos: cc.Vec2 = cc.Vec2.ZERO;
    /** 当前颜色 */
    currentColor = null;

    soundAni:cc.Animation = null;
    blackSoundAni:cc.Animation = null;
    graySoundAni:cc.Animation = null;

    timeLabel:cc.Label = null;
    lb:cc.Label = null;

    currentWayPoint:LianXianWayPoint = null;

    currentLianItem:LevelLianXian_1Item = null;

    nowLianNum:number = -1;

    itemBg:cc.Node = null;

    onLoad() {
        this.blackSoundAni = this.node.getChildByName("soundAni").getComponent(cc.Animation);
        this.graySoundAni = this.node.getChildByName("soundAniGray").getComponent(cc.Animation);
        this.timeLabel = this.node.getChildByName("timeLabel").getComponent(cc.Label);
        this.itemBg = this.node.getChildByName("itemBg");
        this.lb = this.node.getChildByName("lb").getComponent(cc.Label);
        this.soundAni = this.blackSoundAni;
        this.addEvent();
        this.init();
    }

    changeAniNode(isGray:boolean){
        this.soundAni = this.graySoundAni;
        let grayActive = this.graySoundAni.node.active;
        let blackActive = this.blackSoundAni.node.active;
        this.graySoundAni.node.active = blackActive;
        this.blackSoundAni.node.active = grayActive;
        if(isGray){
            this.timeLabel.node.color = cc.Color.GRAY;
            this.lb.node.color = cc.Color.GRAY;
            mainRoot.LevelSystem.getOneTypeBundle(this.level1Script.getLevelInfo().levelType).load("kuang4",cc.SpriteFrame,(err,asset:cc.SpriteFrame)=>{
                if(err){
                    console.log(err);
                    return;
                }
                this.node.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = asset;
            });

        }else{
            this.timeLabel.node.color = cc.Color.WHITE;
            this.lb.node.color = cc.Color.BLACK;
            mainRoot.LevelSystem.getOneTypeBundle(this.level1Script.getLevelInfo().levelType).load("kuang2",cc.SpriteFrame,(err,asset:cc.SpriteFrame)=>{
                if(err){
                    console.log(err);
                    return;
                }
                this.node.getChildByName("bg").getComponent(cc.Sprite).spriteFrame = asset;
            });
        }

    }


    update(dt: number) {
        if (this.isStartSoundTime) {
            this.currentTime -= dt;
            let num = this.currentTime.toFixed(1);
            this.node.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num + "s";
            if (this.currentTime <= 0) {
                this.currentTime = this.oldSoundTime;
                this.isStartSoundTime = false;
                let num1 = this.currentTime.toFixed(1);
                this.node.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num1 + "s";
                this.soundAni.play("soundAniIdle");
                this.level1Script.isPlaySoundNode = null;
                this.level1Script.isPlaySound = false;
            }
        }
    }

    init() {
        this.level1Script = this.levelNode.getComponent(LevelLianXian_1);
        this.currentTime = this.soundTimeLeft + (this.soundTimeRight / 10);
        let soundTimeNum = this.currentTime.toFixed(1);
        this.node.getChildByName("timeLabel").getComponent(cc.Label).string = "" + soundTimeNum + "s";
        this.oldSoundTime = this.currentTime;
    }

    stopSoundAni(){
        if(this.level1Script.isPlaySoundNode)
        this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).soundAni.play("soundAniIdle");
        this.isStartSoundTime = false;
    }

    addEvent() {
        this.node.on(cc.Node.EventType.TOUCH_START, this.moveComponentStart, this);
        this.node.on(cc.Node.EventType.TOUCH_MOVE, this.moveComponentMove, this);
        this.node.on(cc.Node.EventType.TOUCH_END, this.moveComponentEnd, this);
        this.node.on(cc.Node.EventType.TOUCH_CANCEL, this.moveComponentCancel, this);
    }
    removeEvent() {
        this.node.off(cc.Node.EventType.TOUCH_START, this.moveComponentStart, this);
        this.node.off(cc.Node.EventType.TOUCH_MOVE, this.moveComponentMove, this);
        this.node.off(cc.Node.EventType.TOUCH_END, this.moveComponentEnd, this);
        this.node.off(cc.Node.EventType.TOUCH_CANCEL, this.moveComponentCancel, this);
    }

    /** 播放音频的动画 */
    async playSoundAnimation() {
        if(!this.level1Script.sounds[this.currentNum-1] || this.level1Script.sounds[this.currentNum-1] == ""||!this.clickIsPlaySound){
            return;
        }
        if(!this.level1Script.itemVaildIsClick&&this.isBuNengSelect) return;
        if (!this.level1Script.isPlaySoundNode) {
            this.isStartSoundTime = true;
            let path: string = this.level1Script.levelName+"/" + this.level1Script.sounds[this.currentNum - 1];
            managers().soundMgr.stopAllSound();
            await managers().soundMgr.playSound(path).then((id:number)=>{
                this.level1Script.soundId = id;
            }); // 播放对应音效

            this.level1Script.isPlaySoundNode = this.node;
            this.soundAni.play("soundAniPlay");
        }
        else if (this.level1Script.isPlaySoundNode) {
            managers().soundMgr.stopAllSound();
            if (this.level1Script.isPlaySoundNode.uuid == this.node.uuid) {
                this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).isStartSoundTime = false;
                this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).currentTime = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).oldSoundTime;
                let num2 = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).currentTime.toFixed(1);
                this.level1Script.isPlaySoundNode.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num2 + "s";
                this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).soundAni.play("soundAniIdle");
                this.level1Script.isPlaySoundNode = null;
                return;
            }
            this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).isStartSoundTime = false;
            this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).currentTime = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).oldSoundTime;
            let num2 = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).currentTime.toFixed(1);
            this.level1Script.isPlaySoundNode.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num2 + "s";
            this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).soundAni.play("soundAniIdle");
            this.isStartSoundTime = true;
            let path: string = this.level1Script.levelName+"/" + this.level1Script.sounds[this.currentNum - 1];
            managers().soundMgr.playSound(path); // 播放对应音效
            this.level1Script.isPlaySoundNode = this.node;
            this.soundAni.play("soundAniPlay");
        }
    }

    moveComponentStart(touchEvent: cc.Event.EventTouch): void {
        if(!this.level1Script.canTouch) return;
        this.level1Script.redrawAllPointPath();
        if (!this.level1Script.isPlaySound) {
            // touchEvent.stopPropagation();
            if (!this.level1Script.isStartTime)
            this.level1Script.isStartTime = true;
            // if (this.level1Script.currentSelectNode == null && !this.isBuNengSelect) {
                if (this.level1Script.currentSelectNode == null) {
                    if(!this.level1Script.itemVaildIsClick && this.isBuNengSelect){
                        return;
                    }
                    this.level1Script.currentSelectNode = this.node;
                    this.startTouchPos = touchEvent.getLocation();
                    this.currentColors();
                }
            }
            this.node.scale = 1.1;
    }

    moveComponentMove(touchEvent: cc.Event.EventTouch): void {
        if(!this.level1Script.canTouch) return;
        if (!this.level1Script.isPlaySound) {
            touchEvent.stopPropagation();
            if (this.level1Script.currentSelectNode != null) {
                let touchPos: cc.Vec2 = touchEvent.getLocation();
                let distance = Math.sqrt((touchPos.y - this.startTouchPos.y) * (touchPos.y - this.startTouchPos.y) + (touchPos.x - this.startTouchPos.x) * (touchPos.x - this.startTouchPos.x));
                let nextPos: cc.Vec2 = this.node.parent.convertToNodeSpaceAR(touchPos);
                let pos = this.getNodePos(this.level1Script.currentSelectNode);
                if(!this.currentColor){
                    this.currentColors();
                }
                if (this.level1Script.cishuNum == 1 && distance >= 10) {
                    this.level1Script.ctx1.strokeColor = this.currentColor;

                    this.level1Script.ctx1.moveTo(pos.x,pos.y);
                    this.level1Script.ctx1.lineTo(nextPos.x, nextPos.y);     
                    this.level1Script.ctx1.stroke();
                    this.level1Script.cishuNum++;
                    managers().soundMgr.playSound('mainSound/clickWord'); // 点击音效
                }
                else if (this.level1Script.cishuNum != 1 && distance >= 10) {
                    this.level1Script.ctx1.clear();
                    this.level1Script.ctx1.strokeColor = this.currentColor;
                    this.level1Script.ctx1.moveTo(pos.x,pos.y);
                    this.level1Script.ctx1.lineTo(nextPos.x, nextPos.y);
                    this.level1Script.ctx1.stroke();
                    let tag = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item).tagNum;

                    let nodeType= this.nodeRotation;
                    let pNode:cc.Node = null;
                    switch(nodeType){
                        case NODEROTATION.LEFT:{
                                pNode = this.level1Script.rightNode;
                            break;
                        }
                        case NODEROTATION.RIGHT:{
                                pNode = this.level1Script.leftNode;
                            break;
                        }
                    }
                    let pcNodes = pNode.children;
                    for(let i=0;i<pcNodes.length;i++){
                        let cNode = pcNodes[i];
                        let cns = cNode.getComponent(LevelLianXian_1Item);
                        let bound = cNode.getBoundingBoxToWorld();
                        // if(bound.contains(touchEvent.getLocation())&&!cns.isBuNengSelect&&!cns.isTweenAni){
                        if(bound.contains(touchEvent.getLocation())&&!cns.isTweenAni&&(cNode.getComponent(LevelLianXian_1Item).currentNum != this.nowLianNum)){
                            if(cns.isBuNengSelect&&!this.level1Script.itemVaildIsClick) continue;
                            cns.isTweenAni = true;
                            this.level1Script.afterSelectNode = cNode;
                            managers().soundMgr.playSound('mainSound/clickWord');
                            cNode.scale = 1.1;
                            this.level1Script.redrawAllPointPath();
                            // cc.tween(cNode).to(0.1, { scale: 1.1 }).start();
                            this.scheduleOnce(()=>{
                                cns.isTweenAni = false;
                            },0.4);
                            // break;
                        }else if(!bound.contains(touchEvent.getLocation())){
                            cNode.scale = 1;
                            this.level1Script.redrawAllPointPath();
                            cns.isTweenAni = false;
                            if(this.level1Script.afterSelectNode&&this.level1Script.afterSelectNode?.uuid == cns.node.uuid){
                                this.level1Script.afterSelectNode = null;
                            }
                        }
                    }
                }
            }
        }
        else {
            this.level1Script.ctx1.clear();
        }
    }

    moveComponentEnd(touchEvent: cc.Event.EventTouch): void {
        if(!this.level1Script.canTouch) return;
        O1HD.getManagers().soundMgr.playSound("mainSound/clickWord");
        let bound = this.node.getBoundingBoxToWorld();
        touchEvent.stopPropagation();
        if(!this.level1Script.itemVaildIsClick && this.isBuNengSelect){
            return;
        }
        // console.log(this.isStartSoundTime,">>>>>>>>怎么回事>>>>>>>>>>")
        if(this.level1Script.currentSelectNode){
            // 判断是否是同一个类型的节点
            let ns = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item);
            if(ns.nodeRotation == this.nodeRotation){
                // 切换节点
                this.level1Script.currentSelectNode = this.node;
            }else{
                this.level1Script.afterSelectNode = this.node;
                this.moveComponentCancel(touchEvent);
                return;
            }
        }
        if (!this.isStartSoundTime) {
            if(bound.contains(touchEvent.getLocation())){
                // this.level1Script.stopSound();
                // console.log(">>>>>>>>>>")
                this.playSoundAnimation();
            }
        }else{
            this.level1Script.stopSound();
            this.stopSoundAni();
            this.level1Script.isPlaySound = false;
        }
        // if(this.level1Script.currentSelectNode)
        // this.level1Script.currentSelectNode.scale = 1;
        // this.level1Script.redrawAllPointPath();
        // this.level1Script.currentSelectNode = null;
        // this.level1Script.ctx1.clear();
        // this.level1Script.cishuNum = 1;
        // let nodeType= this.nodeRotation;
        // let pNode:cc.Node = null;
        // switch(nodeType){
        //     case NODEROTATION.LEFT:{
        //             pNode = this.level1Script.rightNode;
        //         break;
        //     }
        //     case NODEROTATION.RIGHT:{
        //             pNode = this.level1Script.leftNode;
        //         break;
        //     }
        // }
        // let pcNodes = pNode.children;
        // for(let i=0;i<pcNodes.length;i++){
        //     let cNode = pcNodes[i];
        //     let cns = cNode.getComponent(LevelLianXian_1Item);
        //     cns.isTweenAni = false;
        // }
    }

    bingoAni(tag:number,index:number,isLeft?:boolean){
        this.level1Script.binGoAni(tag,index,isLeft);
    }

    moveComponentCancel(touchEvent: cc.Event.EventTouch): void {
        if(!this.level1Script.canTouch) return;
        if (!this.level1Script.isPlaySound&&this.level1Script.currentSelectNode) {
            // this.level1Script.leftNode.children.forEach((n:cc.Node)=>{
            //     n.scale = 1;
            // });
            // this.level1Script.rightNode.children.forEach((n:cc.Node)=>{
            //     n.scale = 1;
            // });
            this.level1Script.currentSelectNode.scale = 1;
            this.level1Script.redrawAllPointPath();
            let tag = this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item).tagNum;
            let currentNum = this.level1Script.afterSelectNode?.getComponent(LevelLianXian_1Item).currentNum;
            if (this.level1Script.afterSelectNode && tag.includes(currentNum)&&this.level1Script.afterSelectNode&&(this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item).currentNum != this.nowLianNum || this.currentNum ==-1)) {
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.bingo(this.getNodePos(this.level1Script.currentSelectNode),this.getNodePos(this.level1Script.afterSelectNode), this.currentColor,this.level1Script.afterSelectNode);
                let index = tag.indexOf(currentNum);
                this.bingoAni(currentNum,index);
                this.changeAniNode(true);
                this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item).changeAniNode(true);
                // this.le
                let path: string = this.level1Script.levelName+"/" + this.level1Script.sounds[currentNum - 1];
                this.level1Script.isAllCheckDone();
                if( this.level1Script.sounds[currentNum - 1] && this.level1Script.sounds[currentNum-1] != ""){
                    managers().soundMgr.playSound(path,()=>{
                        this.level1Script.checkWin();
                    });
                }else{
                    if(this.sigleSound==""||this.sigleSound==null){
                        this.level1Script.checkWin();
                    }
                }
                if(this.sigleSound != ""){
                    managers().soundMgr.stopAllSound();
                    path = this.level1Script.levelName+"/" + this.sigleSound;
                    managers().soundMgr.playSound(path,()=>{
                        this.level1Script.checkWin();
                    });
                }else{
                    if(this.level1Script.sounds[currentNum - 1] == null || this.level1Script.sounds[currentNum-1] == ""){
                        this.level1Script.checkWin();
                    }
                }

                if((this.level1Script.sounds[currentNum - 1] == null || this.level1Script.sounds[currentNum-1] == "")&&(this.level1Script.sounds[currentNum - 1] && this.level1Script.sounds[currentNum-1] != "")){
                    this.level1Script.checkWin();
                }

                /** 答对之后，停止音效 */
                if (this.level1Script.isPlaySoundNode) {
                    managers().soundMgr.stopAllSound();
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).isStartSoundTime = false;
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).currentTime = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).oldSoundTime;
                    let num2 = this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).currentTime.toFixed(1);
                    this.level1Script.isPlaySoundNode.getChildByName("timeLabel").getComponent(cc.Label).string = "" + num2 + "s";
                    this.level1Script.isPlaySoundNode.getComponent(LevelLianXian_1Item).soundAni.play("soundAniIdle");
                }
                this.level1Script.isPlaySound = false;
                this.level1Script.isPlaySoundNode = null;
                this.level1Script.currentSelectNode.getComponent(LevelLianXian_1Item).isBuNengSelect = true;
                this.level1Script.currentSelectNode = null;
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.level1Script.afterSelectNode = null;
                return;
            }else if(this.level1Script.afterSelectNode){
                this.level1Script.errorSubTime();
                managers().soundMgr.playSound('mainSound/error');// 错误音效
                this.level1Script.currentSelectNode = null;
                this.level1Script.afterSelectNode.scale = 1;
                this.level1Script.redrawAllPointPath();
                this.level1Script.afterSelectNode = null;
                this.level1Script.ctx1.clear();
                this.level1Script.cishuNum = 1;
                return;
            }else {
                this.level1Script.currentSelectNode = null;
                this.level1Script.ctx1.clear();
                this.level1Script.cishuNum = 1;
                return;
            }
        }
    }

    @property()
    sigleSound:string = "";

    protected onDestroy(): void {
        this.removeEvent();
    }

    bingo(moveTo, lineTo, colors: cc.Color,otherNode:cc.Node) {
        managers().soundMgr.playSound('mainSound/hcy1');// 答对的音效
        let meCurrentItem = this.currentLianItem;
        if(meCurrentItem){
            let meotherItem = meCurrentItem.currentLianItem;
            let mecurrentWayPoint = meCurrentItem.currentWayPoint;
            this.currentLianItem = null;
            this.nowLianNum = -1;
            meCurrentItem.nowLianNum = -1;
            meotherItem.currentLianItem = null;
            this.level1Script.removeOnePointPath(mecurrentWayPoint);
            this.currentWayPoint = null;
            meotherItem.currentWayPoint = null;
            this.level1Script.currentYesNum --;
            this.changeAniNode(false);
            meCurrentItem.changeAniNode(false);
            if(meCurrentItem.currentLianItem){
                let t = meCurrentItem.currentLianItem;
                let meotherItem2 = t.currentLianItem;
                let mecurrentWayPoint2 = t.currentWayPoint;
                meCurrentItem.currentLianItem = null;
                if(meotherItem2 && meotherItem2.nowLianNum){
                    meotherItem2.nowLianNum = -1;
                }
                t.nowLianNum = -1;
                if(meotherItem2 && meotherItem2.currentLianItem){
                    meotherItem2.currentLianItem = null;
                }
                this.level1Script.removeOnePointPath(mecurrentWayPoint2);
                t.currentWayPoint = null;
                if(meotherItem2 && meotherItem2.currentWayPoint){
                    meotherItem2.currentWayPoint = null;
                }
                // this.level1Script.currentYesNum --;
                this.changeAniNode(false);
                t.changeAniNode(false);
            }
        }
        if(otherNode.uuid == this.node.uuid){
            if(this.node.uuid == this.level1Script.currentSelectNode.uuid){
                otherNode = this.level1Script.afterSelectNode;
            }else{
                otherNode = this.level1Script.currentSelectNode;
            }
        }

        if(otherNode){
            let os = otherNode.getComponent(LevelLianXian_1Item);
            let oCurrentItem = os.currentLianItem;
            if(oCurrentItem){
                os.nowLianNum = -1;
                oCurrentItem.nowLianNum = -1;
                oCurrentItem.currentLianItem = null;
                os.currentLianItem = null;
                this.level1Script.removeOnePointPath(oCurrentItem.currentWayPoint);
                os.currentWayPoint = null;
                oCurrentItem.currentWayPoint = null;
                this.level1Script.currentYesNum --;
                os.changeAniNode(false);
                oCurrentItem.changeAniNode(false);
            }
        }

        this.level1Script.afterSelectNode.getComponent(LevelLianXian_1Item).isBuNengSelect = true;
        this.level1Script.ctx1.clear();
        // let ctx = this.level1Script.DrawingBoard1.getComponent(cc.Graphics);
        // ctx.strokeColor = colors;
        // ctx.moveTo(moveTo.x, moveTo.y);
        // ctx.lineTo(lineTo.x, lineTo.y);
        // ctx.stroke();
        let oneWayPoint:LianXianWayPoint = {
            startNode: this.node,
            endNode: otherNode,
            color: colors
        }
        this.currentWayPoint = oneWayPoint;
        this.level1Script.addOnePointPath(oneWayPoint);
        this.currentLianItem = otherNode.getComponent(LevelLianXian_1Item);
        otherNode.getComponent(LevelLianXian_1Item).currentLianItem = this;
        otherNode.getComponent(LevelLianXian_1Item).currentWayPoint = oneWayPoint;
        this.nowLianNum = otherNode.getComponent(LevelLianXian_1Item).currentNum;
        otherNode.getComponent(LevelLianXian_1Item).nowLianNum = this.currentNum;
        this.level1Script.redrawAllPointPath();
        this.level1Script.currentYesNum++;
        this.level1Script.cishuNum = 1;

    }

    getNodePos(node:cc.Node){
        let ns = node.getComponent(LevelLianXian_1Item);
        switch(ns.nodeRotation){
            case NODEROTATION.LEFT:{
                let bg = node.getChildByName("bg");
                return cc.v2(node.x + bg.width/2*node.scale,node.y);
            }
            case NODEROTATION.RIGHT:{
                let bg = node.getChildByName("bg");
                return cc.v2(node.x - bg.width/2*node.scale,node.y);
                break;
            }
        }
    }
    
    currentColors() {
        let tagNums = this.level1Script.currentSelectNode?.getComponent(LevelLianXian_1Item).currentNum;
        this.currentColor = cc.color(195, 215, 242);
        while (tagNums) {
            if (tagNums == 1) {
                this.currentColor = cc.color(195, 215, 242);
                return;
            }
            if (tagNums == 2) {
                this.currentColor = cc.color(246, 207, 128);
                return;
            }
            if (tagNums == 3) {
                this.currentColor = cc.color(223, 221, 108);
                return;
            }
            if (tagNums == 4) {
                this.currentColor = cc.color(248, 134, 170);
                return;
            }
            if (tagNums == 5) {
                this.currentColor = cc.color(253, 140, 100);
                return;
            }
            if (tagNums == 6) {
                this.currentColor = cc.color(154, 219, 197);
                return;
            }
            if (tagNums == 7) {
                this.currentColor = cc.color(86, 203, 249);
                return;
            }
            if (tagNums == 8) {
                this.currentColor = cc.color(211, 89, 126);
                return;
            }
            if (tagNums == 9) {
                this.currentColor = cc.color(147, 183, 177);
                return;
            }
            if (tagNums == 10) {
                this.currentColor = cc.color(119, 140, 207);
                return;
            }
            if (tagNums == 11) {
                this.currentColor = cc.color(67, 26, 9);
                return;
            }
            if (tagNums == 12) {
                this.currentColor = cc.color(195, 215, 242);
                return;
            }
            if (tagNums == 13) {
                this.currentColor = cc.color(246, 207, 128);
                return;
            }
            if (tagNums == 14) {
                this.currentColor = cc.color(223, 221, 108);
                return;
            }
            if (tagNums == 15) {
                this.currentColor = cc.color(248, 134, 170);
                return;
            }
            if (tagNums == 16) {
                this.currentColor = cc.color(253, 140, 100);
                return;
            }
            if (tagNums == 17) {
                this.currentColor = cc.color(154, 219, 197);
                return;
            }
            if (tagNums == 18) {
                this.currentColor = cc.color(86, 203, 249);
                return;
            }
            if (tagNums == 19) {
                this.currentColor = cc.color(211, 89, 126);
                return;
            }
            if (tagNums == 20) {
                this.currentColor = cc.color(147, 183, 177);
                return;
            }
            if (tagNums == 21) {
                this.currentColor = cc.color(119, 140, 207);
                return;
            }
            if (tagNums == 22) {
                this.currentColor = cc.color(67, 26, 9);
                return;
            }
            if (tagNums == 23) {
                this.currentColor = cc.color(195, 215, 242);
                return;
            }
            if (tagNums == 24) {
                this.currentColor = cc.color(246, 207, 128);
                return;
            }
            if (tagNums == 25) {
                this.currentColor = cc.color(223, 221, 108);
                return;
            }
            if (tagNums == 26) {
                this.currentColor = cc.color(248, 134, 170);
                return;
            }

        }
    }

}
